﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<div>
    <table class="form ui-jqgrid-htable ui-common-table table table-bordered">
        <tr class="ui-jqgrid-labels">
            <th class="ui-th-column ui-th-ltr" style="text-align:center;">市场价</th>
            <th class="ui-th-column ui-th-ltr" style="text-align:center;"><input type="text" id="MarketPrice" /></th>
        </tr>
        <tr class="ui-jqgrid-labels">
            <th class="ui-th-column ui-th-ltr" style="text-align:center;">YUNSPACE价格</th>
            <th class="ui-th-column ui-th-ltr" style="text-align:center;"><input type="text" id="YunPrice" /></th>
        </tr>
        <tr class="ui-jqgrid-labels">
            <th class="ui-th-column ui-th-ltr" style="text-align:center;">单位</th>
            <th class="ui-th-column ui-th-ltr" style="text-align:center;">
                <select id="unit">

                </select>
            </th>
        </tr>
    </table>
</div>
<script>
    $(function () {
        var F_Id = $.request("F_Id");
        $.ajax({
            url: "/CheckManager/CheckInfos/GetSitePrice?F_Id=" + F_Id,
            dataType: "json",
            async: false,
            success: function (data) {
                resultData = data;
                $('#MarketPrice').val(data.MPrice);
                $('#YunPrice').val(data.YPrice);
                var unit = data.units;
                var len = unit.length;
                for (var i = 0; i < len; i++) {
                    $('#unit').append("<option value='" + unit[i].F_ItemCode + "'>" + unit[i].F_ItemName + "</option>");
                }
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {

            }
        });
    });

    function submitForm(iframeId,detailFrameId) {
        var F_CheckId = $.request("F_CheckId");
        var F_FlowId = $.request("F_FlowId");
        var ApplyType = $.request("ApplyType");
        var F_CheckUserId = $.request("F_CheckUserId");
        var F_Id = $.request("F_Id");

        var YPrice = $("#YunPrice").val();
        var MarketPrice = $('#MarketPrice').val();
        var unit = $('#unit').val();
        var opts = { btn: ['是', '否'] };
        $.modalConfirm('您确定提交吗？', function (flag, index) {
            if (flag) {
                $.submitForm({
                    url: "/CheckManager/CheckInfos/SetSchedule?F_Id=" + F_Id + "&State=1&F_CheckId=" + F_CheckId + "&F_FlowId=" + F_FlowId + "&ApplyType=" + ApplyType + "&F_CheckUserId=" + F_CheckUserId + "&YPrice=" + YPrice + "&MPrice=" + MarketPrice + "&unit=" + unit,
                    success: function (data) {
                        $.loading(false);                        
                        top.frames[detailFrameId].ReloadGridList();   
                        $.modalConfirmClose(index);
                        $.modalFrameClose(iframeId);
                    },
                    close: false
                });
            }
        }, opts);
    }
</script>